import 'package:flutter/material.dart';

class DashBoard extends StatefulWidget {
  @override
  DashBoardState createState() => new DashBoardState();
}

class DashBoardState extends State<DashBoard> {
  List<Map<String, Object>> _indexCardDataList = new List();
  final List<String> notifyMsgs = [
    "第三玩具车间 确定一个新订单",
    "三湘银行提供4000万融资租赁服务",
    "一笔50000元维修订单完成",
    "关于鼓励区内企业使用ERP服务的通知",
    "揭阳工信与三湘银行达成战略合作协议",
    "米国取消塑胶玩具15%关税",
    "企业上链申请等待审批",
  ];
  @override
  void initState() {
    super.initState();
    _indexCardDataList.add({"num": 123, "text": "综合排名"});
    _indexCardDataList.add({"num": 85, "text": "活跃度"});
    _indexCardDataList.add({"num": 42, "text": "企业个数"});
    _indexCardDataList.add({"num": 85, "text": "数字化指数"});
    _indexCardDataList.add({"num": 85, "text": "累计订单"});
    _indexCardDataList.add({"num": 20, "text": "在产订单"});
    _indexCardDataList.add({"num": 132, "text": "上线设备"});
    _indexCardDataList.add({"num": 3, "text": "融资总量"});


  }

  @override
  Widget build(BuildContext context) {
    //super.build(context);
    return CustomScrollView(
      shrinkWrap: true,
      slivers: <Widget>[
        SliverAppBar(
          primary: true, //是否预留高度
          forceElevated: false,
          backgroundColor: Colors.green,
          automaticallyImplyLeading: true,
          titleSpacing: NavigationToolbar.kMiddleSpacing,
          snap: false, //与floating结合使用
          expandedHeight: 100.0, //展开高度
          floating: false, //是否随着滑动隐藏标题
          pinned: true, //是否固定在顶部
          flexibleSpace: FlexibleSpaceBar(
              //可以展开区域，通常是一个FlexibleSpaceBar
              centerTitle: true,
              title: Text("揭阳塑胶产业汇聚平台",
                  style: TextStyle(
                    color: Colors.white,
                    fontSize: 16.0,
                  )),
              background: Image.network(
                //"http://h.hiphotos.baidu.com/image/pic/item/342ac65c103853434cc02dda9f13b07eca80883a.jpg",
                //"http://b.zol-img.com.cn/desk/bizhi/image/6/960x600/1432800027589.jpg",
                //"http://www.themanufacturer.com/wp-content/uploads/2017/11/IIOT.jpg",
                //"https://www.rilheva.com/wp-content/uploads/2017/09/fondo2.jpg",
                "https://iiot.jp/wp-content/uploads/2019/01/dc4775226e5370fa43eeef2d0b421186.jpg",
                //"https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1531798262708&di=53d278a8427f482c5b836fa0e057f4ea&imgtype=0&src=http%3A%2F%2Fh.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F342ac65c103853434cc02dda9f13b07eca80883a.jpg",
                fit: BoxFit.fill,
              )),
        ),
        /*SliverPadding(
          padding: const EdgeInsets.all(20.0),
          sliver: SliverList(
            delegate: SliverChildListDelegate(
              <Widget>[
                const Text('I\'m dedicating every dddday to you!!!!'),
                const Text('Domestic life was never quite my style'),
                const Text('When you smile, you knock me out, I fall apart'),
                const Text('And I thought I was so smart'),
              ],
            ),
          ),
        ),*/
        SliverPadding(
            padding: const EdgeInsets.all(0.0),
            sliver: SliverList(delegate: SliverChildListDelegate(<Widget>[
              Card(
                color: Colors.blue.withAlpha(30),
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: <Widget>[
                    const ListTile(
                      leading: Icon(Icons.album),
                      title: Text('增协同  聚资源  助发展 '),
                      subtitle: Text('正服务于108家链上企业 '),
                    ),
                  ],
                ),
              ),
            ]))),

        SliverGrid(
          gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
            maxCrossAxisExtent: 200.0,
            mainAxisSpacing: 10.0,
            crossAxisSpacing: 10.0,
            childAspectRatio: 4.0,
          ),
          delegate: SliverChildBuilderDelegate(
            (BuildContext context, int index) {
              return Container(
                  alignment: Alignment.center,
                  //color: Colors.teal[100 * (index % 9)],
                  color: Colors.teal[100],
                  child: Column(children: <Widget>[
                    Text(_indexCardDataList[index]["num"].toString(),
                        style: new TextStyle(
                          color: Color.fromARGB(255, 50, 50, 50),
                          fontSize: 22.0,
                        )),
                    Text(_indexCardDataList[index]["text"])
                  ]));
            },
            childCount: _indexCardDataList.length,
          ),
        ),
        SliverFixedExtentList(
          itemExtent: 50.0,
          delegate: SliverChildBuilderDelegate(
            (BuildContext context, int index) {
              return Container(
                alignment: Alignment.center,
                color: Colors.lightBlue[100 * (index % 2)],
                child: Text(notifyMsgs[index]),
              );
            },
            childCount: notifyMsgs.length,
          ),
        ),
      ],
    );
  }
}
